SlkStore.CreateAssignment Method

Creates a new SharePoint Learning Kit assignment.

Parent Type: SlkStore

Namespace: Microsoft.SharePointLearningKit

Assembly: Microsoft.SharePointLearningKit.dll

Syntax
C#

public AssignmentItemIdentifier CreateAssignment (
SPWeb destinationSPWeb,
string location,
Nullable<int> organizationIndex,
SlkRole slkRole,
AssignmentProperties properties

)

Parameters

destinationSPWeb

The SPWeb to create the assignment in.

location

The MLC SharePoint location string that refers to the e-learning package or non-e-learning document to assign. Use SharePointPackageStore.GetLocation to construct this string.

organizationIndex

The zero-based index of the organization within the e-learning content to assign; this is the value that's used as an index to ManifestReader.Organizations. If the content being assigned is a non-e-learning document, use null for organizationIndex.

slkRole

The SlkRole to use when creating the assignment. Use SlkRole.Learner to create a self-assigned assignment, i.e. an assignment with no instructors for which the current learner is the only learner. Otherwise, use SlkRole.Instructor.

properties

Properties of the new assignment. Note that, within AssignmentProperties.Instructors and AssignmentProperties.Learners, all properties except UserId are ignored. Also, if slkRole is SlkRole.Learner, then AssignmentProperties.Instructors must be empty, and AssignmentProperties.Learners must contain only the current user. The SPSiteGuid, SPWebGuid, Location, and CreatedById properties are ignored when creating a new assignment.

Exceptions
Exception type Condition
InvalidOperationException

destinationSPWeb is not in the SPSite that this SlkStore is associated with.

SafeToDisplayException

An error occurred that can be displayed to a browser user.

UnauthorizedAccessException

location refers to a file that the user does not have access to, the user is not a Reader on destinationSPWeb, or the user is trying to create an assignment with other learners or instructors but the assignment is self-assigned.

NotAnInstructorException

The user is not an instructor on destinationSPWeb and the assignment is not self-assigned.

Remarks

When creating a self-assigned assignment, take care to ensure that AssignmentProperties.AutoReturn is true, otherwise the learner assignments will never reach LearnerAssignmentState.Final state.

Security:  If slkRole is SlkRole.Instructor, this operation fails if the current user doesn't have SLK instructor permissions on destinationSPWeb. Also fails if the current user doesn't have access to the package/file.